package 字母收集;

import java.util.Scanner;

public class Main {
    static int N = 510;
    static char[][] g = new char[N][N];
    static int[][] f = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        for (int i = 1; i <= n; i++) {
            String s = in.next();
            for (int j = 1; j <= m; j++) {
                g[i][j] = s.charAt(j - 1);
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                int t = 0;
                char ch = g[i][j];
                if (ch == 'l') {
                    t = 4;
                } else if (ch == 'o') {
                    t = 3;
                } else if (ch == 'v') {
                    t = 2;
                } else if (ch == 'e') {
                    t = 1;
                }
                f[i][j] = Math.max(f[i - 1][j], f[i][j - 1]) + t;
            }
        }
        System.out.println(f[n][m]);
    }
}
